package com.atguigu.app.func;

import com.atguigu.utils.DateFormatUtil;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.flink.streaming.api.functions.windowing.AllWindowFunction;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.flink.streaming.api.windowing.windows.Window;
import org.apache.flink.util.Collector;

public class MyAllWindowFunction<T, W extends TimeWindow> implements AllWindowFunction<T,T,W> {
    @Override
    public void apply(W w, Iterable<T> iterable, Collector<T> collector) throws Exception {
        T next = iterable.iterator().next();
        BeanUtils.setProperty(next,"ts",System.currentTimeMillis());
        BeanUtils.setProperty(next,"stt", DateFormatUtil.toYmdHms(w.getStart()));
        BeanUtils.setProperty(next,"edt",DateFormatUtil.toYmdHms(w.getEnd()));
        System.out.println("chen");
        collector.collect(next);
    }
}
